cmake_minimum_required (VERSION 2.8)
project (fileserver)

# 设置生成的二进制文件放在bin目录下
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)


# 设置头文件搜索的路径
include_directories(${PROJECT_SOURCE_DIR}/src/include)
include_directories(${PROJECT_SOURCE_DIR}/src/common)
link_directories (/usr/lib64/mysql) # 库文件搜索路径

# cmake支持C++11
add_compile_options(-std=c++11) 
set(CMAKE_CXX_FLAGS "-fpermissive -g ${CMAKE_CXX_FLAGS}")

# 设置debug模式，如果没有这一行将不能调试设断点
set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -g)


# 定义变量，汇总所有的源代码文件
set(SERVER_SRC 
    ./src/server/main.cc 
    ./src/server/service.cc
    ./src/common/common.cc
    ./src/common/md5.cc
    ./src/common/mysql.cc)
set(CLIENT_SRC 
    ./src/client/main.cc 
    ./src/client/command.cc
    ./src/common/common.cc
    ./src/common/md5.cc)

# 生成可执行文件
add_executable(fileserver ${SERVER_SRC})
# 给server端连接libmysqlclient.so库
target_link_libraries (fileserver mysqlclient)
add_executable(fileclient ${CLIENT_SRC})